<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreatePostRecord extends AbstractMigration
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $item = $this->table('post_record', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci','comment' => '文件记录表']);

        $item->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('post_id', 'integer', ['default' => 0, 'comment' => '文件ID'])
            ->addColumn('user_id', 'integer', ['default' => 0, 'comment' => '创建人用户ID'])
            ->addColumn('chat_name', 'string', ['default' => '', 'limit' => 255, 'comment' => '会话名称'])
            ->addColumn('created', 'integer', ['limit' => 11, 'null' => false, 'default' => 0, 'comment' => '创建时间'])
            ->addColumn('updated', 'integer',  ['limit' => 11, 'null' => false, 'default' => 0, 'comment' => '更新时间'])
            ->addColumn('tenant_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '租户ID'])
            ->addColumn("chat_global_id","string", [ 'default' => '', 'limit' => 100, 'comment' => '群聊ID'])
            ->addColumn('last_open_time','integer', ['limit' => 11, 'null' => true, 'default' => 0, 'comment' => '最后一次打开时间'])
            ->save();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $this->dropTable('post_record');
    }
}
